package com.sky.controller.user;


import com.sky.constant.StatusConstant;
import com.sky.pojo.Setmeal;
import com.sky.result.Result;
import com.sky.service.user.UserSetmealService;
import com.sky.vo.DishItemVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/user/setmeal")
@Api(tags = "根据分类id查询套餐")
public class UserSetmealController {

    @Autowired
    private UserSetmealService setmealService;

    @GetMapping("list")
    @ApiOperation("根据分类id查询套餐")
    public Result<List<Setmeal>> queryList(Long categoryId){
        log.info("根据分类id查询套餐:{}",categoryId);
            List<Setmeal> list = setmealService.queryList(categoryId);
            return Result.success(list);
        }


    @GetMapping("/dish/{setmealId}")
    @ApiOperation("根据套餐id查询包含的菜品")
    public Result<List<DishItemVO>> findById(@PathVariable Integer setmealId){
        log.info("根据套餐id查询包含的菜品：{}",setmealId);
        List<DishItemVO> list = setmealService.findById(setmealId);
        return Result.success(list);

    }

}
